﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BEG.Core;
using BEG.Core.Interface;
using BEG.Model.Classifiers;
using BEG.Model.Projections;
using GalaSoft.MvvmLight.Command;
using System.Windows.Input;
using System.Windows.Forms;
using System.Xml;
using System.IO;

namespace WebReportGeneratorVer2
{
    public class WebGeneratorModule: IModule
    {
            private ExtensionContext extensionContext;
            public string Name { get { return "WebGeneratorModule"; } }

            /// <summary>
            /// Помещаем пункт генерации отчета на форму
            /// </summary>
            /// <param name="context"></param>
            public void Initialilize(ExtensionContext context)
            {
                extensionContext = context;

                var group = extensionContext.MenuExtensionPoint.AddRibbonPageGroup("ReportGeneration", "Генерация Web-отчётов");

                var testCommand = new RelayCommand(OnOpenGeneratorFormExecuted);
                var exportMenuItem = extensionContext.MenuExtensionPoint.AddMenuItem("smReport", "Экспорт в html", "exportMenuItem",
                null, "", testCommand, null, null);
                extensionContext.MenuExtensionPoint.AddRibbonItem(group, exportMenuItem);
            }

            /// <summary>
            /// Запуск формы генерации отчета
            /// </summary>
            private void OnOpenGeneratorFormExecuted()
            {
                var currentProject = extensionContext.GlobalState.CurrentProject;

                GeneratorForm form = new GeneratorForm(currentProject);
                form.Show();
            }
            public void OnClosing()
            {
                //do nothing
            }
        }
    }
